package com.xcf.controller.business.bookingcargo;

import cn.com.xcf.dao.model.FactBookingNote;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.xcf.controller.base.BaseController;
import com.xcf.controller.base.ExportDataHandler;
import com.xcf.entity.Page;
import com.xcf.service.business.bookingcargo.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping(value = "/test")
public class TestController  implements ExportDataHandler {

	@Autowired
	private TestService testService;



	//点击保存按钮
	@RequestMapping(value="list")
	@ResponseBody
	public String list(){
		PageHelper.startPage(1, 1);
		List<Map> list = testService.queryByPage();
		System.out.println(list.size()+"   "+list);
		System.out.println(JSONObject.toJSONString(list));

		return "{\"total\":50,\"rows\": [\n" +
				"  {\n" +
				"    \"rowNum\": \"1\",\n" +
				"    \"cataId\": \"852\",\n" +
				"    \"cataNo\": \"10000809\",\n" +
				"    \"cataTitle\": \"\",\n" +
				"    \"cataObject\": \"4\",\n" +
				"    \"cataObjectName\": \"华悦购物\",\n" +
				"    \"cataType\": \"1\",\n" +
				"    \"cataTypeName\": \"默认\",\n" +
				"    \"cataeditstatus\": \"2\",\n" +
				"    \"cataeditstatusName\": \"待提交\",\n" +
				"    \"cataPublishStatus\": \"2\",\n" +
				"    \"cataPublishName\": \"已发布\",\n" +
				"    \"cataRemark\": \"banner广告\",\n" +
				"    \"cataObjectType\": \"2\",\n" +
				"    \"apptypename\": \"销售\",\n" +
				"    \"cataEndDate\": \"2014-09-27\",\n" +
				"    \"holyCreateTime\": \"2013-11-24 16:02:04\",\n" +
				"    \"holyUpdateTime\": \"\",\n" +
				"    \"catapushtime\": \"\",\n" +
				"    \"holyCreateUser\": \"lhcs\"\n" +
				"  },{\n" +
				"    \"rowNum\": \"1\",\n" +
				"    \"cataId\": \"853\",\n" +
				"    \"cataNo\": \"10000809\",\n" +
				"    \"cataTitle\": \"\",\n" +
				"    \"cataObject\": \"4\",\n" +
				"    \"cataObjectName\": \"华悦购物\",\n" +
				"    \"cataType\": \"1\",\n" +
				"    \"cataTypeName\": \"默认\",\n" +
				"    \"cataeditstatus\": \"2\",\n" +
				"    \"cataeditstatusName\": \"待提交\",\n" +
				"    \"cataPublishStatus\": \"2\",\n" +
				"    \"cataPublishName\": \"已发布\",\n" +
				"    \"cataRemark\": \"banner广告\",\n" +
				"    \"cataObjectType\": \"2\",\n" +
				"    \"apptypename\": \"销售\",\n" +
				"    \"cataEndDate\": \"2014-09-27\",\n" +
				"    \"holyCreateTime\": \"2013-11-24 16:02:04\",\n" +
				"    \"holyUpdateTime\": \"\",\n" +
				"    \"catapushtime\": \"\",\n" +
				"    \"holyCreateUser\": \"lhcs\"\n" +
				"  }\n" +
				"]\n" +
				"}";
	}

	@Override
	public List getData(String type, Map param, Page page) {

		Map map = Maps.newHashMap();
		map.put("name" , "king23");
		map.put("age" , "23");
		return Lists.newArrayList(map);
	}

	@Override
	public String getService() {
		return  getClass().getSimpleName();
	}

	@Override
	public Map<String, String> setNames() {
		Map m = new HashMap(3);
		m.put("test","test.xls");
		m.put("testName","导出测试.xls");
		m.put("testModule",getService());
		return m;
	}
}
